package vip.xiaonuo.biz.modular.lancerShopCart.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.biz.modular.lancerShopCart.service.BizShopCartItemService;
import vip.xiaonuo.biz.modular.pojo.domain.BizShopCartItem;
import vip.xiaonuo.biz.modular.pojo.dto.common.CommonDeleteDTO;
import vip.xiaonuo.biz.modular.pojo.dto.common.CommonDetailDTO;
import vip.xiaonuo.biz.modular.pojo.dto.edit.ShopCartItemEditDTO;
import vip.xiaonuo.biz.modular.pojo.dto.page.ShopCartItemPageDTO;
import vip.xiaonuo.common.pojo.CommonResult;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import java.util.List;

@Api(tags = "购物车(C端)")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@Validated
@RestController("userClientShopCartItemController")
@RequestMapping("/biz/client/shopCartItem")
public class ClientShopCartItemController {
    @Autowired
    private BizShopCartItemService ShopCartItemService;
    @ApiOperationSupport(order = 1)
    @ApiOperation("C端购物车分页")
    @GetMapping("page")
    public CommonResult<Page<BizShopCartItem>> page(@Valid ShopCartItemPageDTO dto) {
        Page<BizShopCartItem> res = ShopCartItemService.pageClient(dto);
        return CommonResult.data(res);
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation("C端加入购物车")
    @GetMapping("/addGoods/{id}/{count}")
    public CommonResult<String> addGoods(@PathVariable String id,@PathVariable Integer count) {
        ShopCartItemService.addGoods(id,count);
        return CommonResult.ok();
    }

    @ApiOperationSupport(order = 4)
    @ApiOperation("C端购物车删除")
    @GetMapping("/delete/{id}")
    public CommonResult<String> delete(@PathVariable String id) {
        ShopCartItemService.deleteClient(id);
        return CommonResult.ok();
    }
}